package cn.itcast.service.impl;

import cn.itcast.Product;
import cn.itcast.dao.ProductDao;
import cn.itcast.service.ProductService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class ProductServiceImpl implements ProductService {

    @Autowired
   private ProductDao productDao;

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<Product> findAll(int page ,int size) {
        PageHelper.startPage(page,size);
        List<Product> list = productDao.findAll();
        return list;
    }

    /**
     * 添加用户
     * @param product
     */
    @Override
    public void save(Product product) {
        productDao.save( product);
    }



    /**
     * 根据ids删除产品
     * @param productIds
     */
    @Override
    public void delByIds(String[] productIds) {
        for (String productId : productIds) {
            productDao.delById(productId);
        }
    }


}
